/**
 * @author @xsomnus666_xiawenye★
 * @since 2019/6/19 0019 18:18
 * - Stay Hungry, Stay Foolish
 * - Just do it
 */
class Solution {

    public ListNode mergeTwoLists(ListNode l1, ListNode l2) {

        if (l2 == null) {
            return l1;
        }

        if (l1 == null) {
            return l2;
        }

        if (l1.val > l2.val) {
            ListNode retNode = new ListNode(l2.val);
            retNode.next = mergeTwoLists(l1, l2.next);
            return retNode;
        } else {
            ListNode retNode = new ListNode(l1.val);
            retNode.next =mergeTwoLists(l1.next, l2);
            return retNode;
        }

    }


    public static void main(String[] args) {
        ListNode l1 = new ListNode(new int[]{1, 2, 4});
        ListNode l2 = new ListNode(new int[]{1, 3, 4});

        System.out.println(new Solution().mergeTwoLists(l1, l2));

    }

}